package com.ruoyi.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.device.domain.SysAppUser;
import com.ruoyi.device.service.ISysAppUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小程序注册Controller
 * 
 * @author zz
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/device/appuser")
public class SysAppUserController extends BaseController
{
    @Autowired
    private ISysAppUserService sysAppUserService;

    /**
     * 查询小程序注册列表
     */
    @PreAuthorize("@ss.hasPermi('system:appuser:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysAppUser sysAppUser)
    {
        startPage();
        List<SysAppUser> list = sysAppUserService.selectSysAppUserList(sysAppUser);
        return getDataTable(list);
    }

    /**
     * 导出小程序注册列表
     */
    @PreAuthorize("@ss.hasPermi('system:appuser:export')")
    @Log(title = "小程序注册", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAppUser sysAppUser)
    {
        List<SysAppUser> list = sysAppUserService.selectSysAppUserList(sysAppUser);
        ExcelUtil<SysAppUser> util = new ExcelUtil<SysAppUser>(SysAppUser.class);
        util.exportExcel(response, list, "小程序注册数据");
    }

    /**
     * 获取小程序注册详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:appuser:query')")
    @GetMapping(value = "/{regId}")
    public AjaxResult getInfo(@PathVariable("regId") Long regId)
    {
        return success(sysAppUserService.selectSysAppUserByRegId(regId));
    }

    /**
     * 新增小程序注册
     */
    @PreAuthorize("@ss.hasPermi('system:appuser:add')")
    @Log(title = "小程序注册", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAppUser sysAppUser)
    {
        return toAjax(sysAppUserService.insertSysAppUser(sysAppUser));
    }

    /**
     * 修改小程序注册
     */
    @PreAuthorize("@ss.hasPermi('system:appuser:edit')")
    @Log(title = "小程序注册", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAppUser sysAppUser)
    {
        return toAjax(sysAppUserService.updateSysAppUser(sysAppUser));
    }

    /**
     * 删除小程序注册
     */
    @PreAuthorize("@ss.hasPermi('system:appuser:remove')")
    @Log(title = "小程序注册", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regIds}")
    public AjaxResult remove(@PathVariable Long[] regIds)
    {
        return toAjax(sysAppUserService.deleteSysAppUserByRegIds(regIds));
    }
}
